<template>
  <div>
    <van-nav-bar title="编辑" left-arrow @click-left="goback">
      <template #right>
        <img src="../assets/个人中心/fanhuishouye.png" width="20" alt="" />
      </template>
    </van-nav-bar>
    <div class="t">
      <van-field
        v-model="custName"
        required
        label="客户姓名"
        input-align="right"
      />
      <van-field
        v-model="telephone"
        required
        label="联系方式"
        input-align="right"
      />
    </div>
    <div class="b">
      <van-field v-model="education" label="学历" input-align="right" />
      <van-field v-model="age" label="年龄" input-align="right" />
      <van-field v-model="sex" label="性别" input-align="right" />
      <van-field v-model="cityName" label="所属城市" input-align="right" />
      <van-field v-model="company" label="公司名称" input-align="right" />
      <van-field v-model="position" label="职务" input-align="right" />
    </div>
    <button @click="xiugai">确认修改</button>
  </div>
</template>




<script>
import { TJCust } from "../request/api";
export default {
  data() {
    return {
      // 客户名称
      custName: "",
      //   所属地市
      cityName: "",
      // 公司名称
      company: "",
      // 职务
      position: "",
      // 联系方式
      telephone: "",
      // 学历
      education: "",
      //性别
      sex: "",
      //年龄
      age: "",
      //客户id
      id: "",
    };
  },
  created() {
    this.id = this.$route.query.id;
    console.log(this.$route.query.text);
    // 客户名称
    this.custName = this.$route.query.text.custName;
    //   所属地市
    this.cityName = this.$route.query.text.cityName;
    // 公司名称
    this.company = this.$route.query.text.company;
    // 职务
    this.position = this.$route.query.text.position;
    // 联系方式
    this.telephone = this.$route.query.text.telephone;
    // 学历
    this.education = this.$route.query.text.education;
    //性别
    this.sex = this.$route.query.text.sex;
    //年龄
    this.age = this.$route.query.text.age;
  },
  methods: {
    goback() {
      this.$router.push({
        path: "/customerXQ",
        query: {
          id: this.id,
        },
      });
    },
    xiugai() {
      TJCust({
        // 客户名称
        custName: this.custName,
        //   所属地市
        cityName: this.cityName,
        // 公司名称
        company: this.company,
        // 职务
        position: this.position,
        // 联系方式
        telephone: this.telephone,
        // 学历
        education: this.education,
        //性别
        sex: this.sex,
        //年龄
        age: this.age,
        id: this.id,
      }).then((res) => {
        if (res.errCode == 0) {
          this.goback();
        }
      });
    },
  },
};
</script>
 
<style lang = "less" scoped>
/deep/ .van-nav-bar__content {
  background: #003399;
  .van-nav-bar__title {
    color: #fff;
  }
  .van-icon {
    color: #fff;
  }
}
.t {
  background-color: #fff;
  padding: 10px;
  box-sizing: border-box;
  margin-bottom: 10px;
}
button {
  border: 0;
  width: 80%;
  height: 50px;
  text-align: center;
  line-height: 50px;
  margin-left: 35px;
  background-color: #003399;
  border-radius: 30px;
  color: #fff;
  margin-top: 180px;
}
</style>